import request from '@/config/axios'

export interface VoteVO {
  id: number
  siteId: number
  title: string
  description: string
  beginDate: Date
  endDate: Date
  voteInterval: number
  voteNum: number
  voteMode: number
  voteMultiple: number
  enabled: number
  userId: number
}

// 查询投票列表
export const getVotePage = async (params) => {
  return await request.get({ url: '/cms/vote/page', params })
}

// 查询投票详情
export const getVote = async (id: number) => {
  return await request.get({ url: '/cms/vote/get?id=' + id })
}

// 新增投票
export const createVote = async (data: VoteVO) => {
  return await request.post({ url: '/cms/vote/create', data })
}

// 修改投票
export const updateVote = async (data: VoteVO) => {
  return await request.put({ url: '/cms/vote/update', data })
}

// 删除投票
export const deleteVote = async (id: number) => {
  return await request.delete({ url: '/cms/vote/delete?id=' + id })
}

// 导出投票 Excel
export const exportVoteApi = async (params) => {
  return await request.download({ url: '/cms/vote/export-excel', params })
}
